// import Mock, { Random } from "mockjs";
import { resultSuccess, resultError } from "../utils";

export default [
	{
		url: "/mock/getRoleRoutes",
		method: "post",
		response: ({ body }) => {
			const { roles } = body;
			const rolesMap = {
				admin: [
					"home",
					"system",
					"user",
					"role",
					"iconList",
					"elementPlusIcons",
					"fontAwesomeIcons",
					"iconfontIcons",
					"demo",
					"editorDemo",
					"noticeBarDemo",
					"iconSelectorDemo",
					"iconDemo",
					"tableDemo",
					"filterDemo",
					"filterDetails",
					"filterDetails1",
					"map",
				],
				common: [
					"home",
					"iconList",
					"elementPlusIcons",
					"fontAwesomeIcons",
					"iconfontIcons",
					"demo",
					"editorDemo",
					"noticeBarDemo",
					"iconSelectorDemo",
					"iconDemo",
					"tableDemo",
					"filterDemo",
					"filterDetails",
					"filterDetails1",
					"map",
				],
				test: ["home", "system", "user", "role"],
			};
			if (roles && roles.length > 0) {
				const res = Array.from(new Set(roles.map(item => rolesMap[item]).flat()));
				return resultSuccess(res);
			} else {
				return resultError({}, "角色不存在，请重新登录");
			}
		},
	},
];
